package com.six.flowerShopper.entity

import com.baomidou.mybatisplus.annotation.FieldStrategy
import com.baomidou.mybatisplus.annotation.IdType
import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.fasterxml.jackson.annotation.JsonFormat
import com.gitee.sunchenbin.mybatis.actable.annotation.*
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant
import org.apache.ibatis.type.JdbcType
import java.io.Serializable
import java.util.Date


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 10/26/22
 * @Software: IntelliJ IDEA
 */
/*购买记录*/
@Table(value = "purchaseHistory", comment = "鮮花種類")
@TableCharset(MySqlCharsetConstant.UTF8)
@TableEngine(MySqlEngineConstant.InnoDB)
class PurchaseHistory() : Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    @IsKey
    @Column(comment = "主键id", isAutoIncrement = true)

    var id: Int = 0

    @Column(name = "userId", type = MySqlTypeConstant.INT, isNull = false, defaultValue = "0")
    @TableField(
        value = "userId",
        insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY
    )

    var userId: Int = 0//用户Id

    @Column(name = "flowerId", type = MySqlTypeConstant.INT, isNull = false, defaultValue = "0")
    @TableField(
        value = "flowerId",
        insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY
    )

    var flowerId: Int = 0//鲜花Id

    @Column(name = "flowerCount", type = MySqlTypeConstant.INT, isNull = false, defaultValue = "0")
    @TableField(
        value = "flowerCount",

        insertStrategy = FieldStrategy.NOT_EMPTY,
        updateStrategy = FieldStrategy.NOT_EMPTY
    )

    var flowerCount: Int = 0 //购买鲜花数量

    @Column(name = "discount", type = MySqlTypeConstant.INT, isNull = false, defaultValue = "0")
    @TableField(
        value = "discount",
        insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY
    )
    var discount: Int = 0 //使用折扣力度


    @Column(name = "buyTime", type = MySqlTypeConstant.DATE, isNull = false)
    @TableField(
        value = "buyTime",
        insertStrategy = FieldStrategy.NOT_EMPTY,
        updateStrategy = FieldStrategy.NOT_EMPTY
    )
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    var buyTime: Date = Date() //消费时间

    companion object {}

    override fun toString(): String {
        return "PurchaseHistory(id=$id, userId=$userId, flowerId=$flowerId, flowerCount=$flowerCount, discount=$discount, buyTime=$buyTime)"
    }


}